<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style type="text/css">
        canvas{
            border: 1px solid red;
        }
    </style>
</head>
<body>
<canvas width="600" height="600" id="can">您的浏览器不支持画布</canvas>
<script type="text/javascript">
       //1、获取画布
    var can=document.getElementById("can");
       //2、获取画笔
    var pen=can.getContext("2d");
       //beginPath()-----开始路径
       pen.beginPath();
       pen.moveTo(100,150);
       pen.lineTo(100,300);
       pen.lineTo(300,300);
       //设置边框的样式
       pen.strokeStyle="red";
       pen.lineWidth="10";
       //设置填充的样式，如果调用fillStyle，后边必须跟着调用fill进行填充
       pen.fillStyle="blue";
       pen.fill();
//       pen.lineTo(100,150);
       //closePath()关闭路径，具有自动闭合的功能
       pen.closePath();
       pen.stroke();




</script>
</body>
</html>